/*
 * Servo_Driver.c
 *
 *  Created on: Mar 5, 2024
 *      Author: DengZicheng
 */
#include "../Servo/Servo_Driver.h"

int now_degree;

void init_servo(){
	__HAL_TIM_SET_COMPARE(&htim3,TIM_CHANNEL_1,150);
}

void servo_degree_contrll(int degree){
	if(degree<0)degree=0;
	if(degree>180)degree=180;
//	degree=(int)(100*((double)degree/180)+40);
	degree=10*degree/9+50;
	__HAL_TIM_SET_COMPARE(&htim3,TIM_CHANNEL_1,degree);
	now_degree=degree;
}

int get_servo_degree(){
	return now_degree;
}


